home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Triad.dxr / playing cards_57_tableau cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  2.6 KB  |  97 lines

  1. property spriteNum, motion, location, row
  2. global tableau, getlist, equal, currentsel, godlist, foundation, points, stock
  3.  
  4. on beginSprite me
  5.   if not listp(tableau) then
  6.     tableau = [:]
  7.   end if
  8.   row = determinerow()
  9.   if not objectp(tableau[row]) then
  10.     tableau.addProp(row, new(script("card pile")))
  11.   end if
  12.   if tableau[row].getcardcount() < 1 then
  13.     sprite(spriteNum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  14.     stock.cards.deleteAt(1)
  15.     tableau[row].addCard(spriteNum)
  16.   end if
  17.   location = sprite(spriteNum).loc
  18. end
  19.  
  20. on mouseDown me
  21.   if tableau[row].getcardcount() > 0 then
  22.     if spriteNum = tableau[row].getlastcard().spnum then
  23.       puppetSound(3, member("pick card", "100GPak Generic SFX"))
  24.       sprite(spriteNum).locZ = spriteNum + 1000
  25.       getlist = tableau[row]
  26.       motion = timeout(string(spriteNum) && "motion").new(5, #moving, me)
  27.     end if
  28.     if sprite(spriteNum).member = member("empty", "playing cards") then
  29.       sendSprite(spriteNum - 1, #mouseDown)
  30.     end if
  31.   end if
  32. end
  33.  
  34. on moving me
  35.   if the mouseDown then
  36.     sprite(spriteNum).loc = the mouseLoc
  37.   else
  38.     if the mouseUp then
  39.       sprite(spriteNum).locZ = spriteNum
  40.       motion.forget()
  41.       abort()
  42.     end if
  43.   end if
  44. end
  45.  
  46. on mouseUp me
  47.   if equal then
  48.     puppetSound(3, member("pick card", "100GPak Generic SFX"))
  49.     sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
  50.     sprite(spriteNum).member = member("empty", "playing cards")
  51.     godlist.addCard(currentsel)
  52.     sprite(spriteNum).loc = location
  53.     tableau[row].cards.deleteOne(tableau[row].getlastcard())
  54.     if objectp(foundation[sprite(currentsel).row]) then
  55.       points = points + 10
  56.     end if
  57.     equal = 0
  58.     currentsel = 0
  59.     godlist = VOID
  60.     getlist = VOID
  61.     repeat with i = 87 to 90
  62.       if tableau[sprite(i).row].getcardcount() = 0 then
  63.         next repeat
  64.       end if
  65.       sprite(i).loc = tableau[sprite(i).row].getlastcard().location
  66.     end repeat
  67.     checkwin()
  68.   else
  69.     if not equal then
  70.       if sprite(spriteNum).member.name <> "empty" then
  71.         puppetSound(3, member("drop card", "100GPak Generic SFX"))
  72.         getlist = VOID
  73.         sprite(spriteNum).loc = location
  74.       end if
  75.     end if
  76.   end if
  77.   checkwin()
  78. end
  79.  
  80. on determinerow me
  81.   if (spriteNum >= 31) and (spriteNum <= 44) then
  82.     return #one
  83.   else
  84.     if (spriteNum >= 45) and (spriteNum <= 58) then
  85.       return #two
  86.     else
  87.       if (spriteNum >= 59) and (spriteNum <= 72) then
  88.         return #three
  89.       else
  90.         if (spriteNum >= 73) and (spriteNum <= 86) then
  91.           return #four
  92.         end if
  93.       end if
  94.     end if
  95.   end if
  96. end
  97.